code fixes (thanks to @jubianchi)