Added comments, changed method names and organization