fix Unhandled exceptions and whitespace pasting problem