Lots of refactoring and added pentagon class (untested)