Refactor geometry stuff into separate class.