DB table relationships added, moved some code, cleaned up some code.