Moved some functions to other files, cleaned up unused files