Fix several important bugs (precise)