some cleaning up, some fixing bugs