Fixed the broken bits

Still requires full testing.