Eliminated some safety checks to make things more flexible
Renamed variables for clarity.
Added documentation.
Moved stopat into calq for better modularity.