Enable demonize function. Clean up code