Tightening up code, added comments, added snap on resize