Added all server functionality and fixed bugs