updated entity definitions, and cleaned up some code.