Fixed rotation issues, cleaned up and added comments.