Improved cleandatabase command

Improved cleandatabase command, can now be used by the console