dead code removal, fixed lots of type coercion