Some code cleaning, started refactoring methods for online use
Major refactoring for database complete