Applying frange() patch by ChrisOelmueller

Slightly modified frange() to be more robust and fixed the ceil() call.

fixes #725