ENH: added unit conversion helper

Separated unit conversion to simplify the code. Removed many comments.