A small overhaul

Tried to reduce as much code as possible.