Fixed some bugs and continued porting