Cleaned up code for submisssion.