Clean-up of logic