fixed lots of code problems in framework