Code is mostly cleaned up, ready for geometry calculations