bunch of fixes from Horv's feedback