Major update

Update of code. Couldn't test with many users, although it should work.