cleanup and moving model class code around to improve readability