Performance Tuning

For comprehensions over ranges and at least some sequences are quite slow. This pull request includes new convenience functions that wrap while() loops, and replaces many for-comprehensions with while loops.