Code cleanup and moving