fixed bugs that would crash the server