keep good code style, keep memory leak away

please fix similar problems in other files.