changes and small hacks to make it work on the server;