Replace tabs with spaces
Rewrite calculation to better handle clocking cases