refactoring error_checking and some undo

user specific undo for profile not implemented yet.