fix padlock crash in debug and some more minor issues.

Signed-off-by: PlutoniumHeart <zhitaoli.hust@gmail.com>