Cleaning up

The code is a mess, let's organize a bit