Cleaned up a bunch of geometry functions.