Added more structures and organized code better