Major changes

Address issues with security.
Changed completely authorization

Note: not well tested