Cleaned up code, added more comments and improved starting positions.