Clean up

Relocated things, cleaned up functions