[refactoring] Make each function for existing codes
Improve error check for g:restart_save_fn
Support maximized window restoration