Latest changes. Fixed some bugs, made some new ones.