Started cleaning up the code