last minute bugs fixed
pukked in from dev branch