Implemented shape validation, major refactor