fixed 3 bugs and some inconsistency