Fixing bugs and moving classes into more appropriate packages