Fixed some broken code and removed junk files