Cleaned up a bit and made more const correct