#252 : Clean code and remove old classes

Cleaned old code from previous version, fixed some warnings and improve
performance by using caching for access rights and prevent many
unnecessary sql accesses.