misc fixes from Stuart's comments

@lileicc 

Fixed almost everything, except array / matrix mess.