Lots of small changes before porting to Max 7