Added Logging and User Groups management. Some bug-fixes and optimisations.

Added Logging and User Groups management. Some bug-fixes and optimisations.