Made some small changes to ensure it works with server