Cleaned up backend code a bit