Fixed movement, Added session restoration

Also more refactoring. Thanks to woder22 for movement fix.