major improvements from Derek Mead