simplify, fix obvious bugs