Fixed some bugs, renamed packages, cleaned unused code.