Fixed up some bugs in the backend
Fixed bugs from merge