Last commit before first merge, cleaned some code