Revert "Loop optimizations and some cool tests!"

This reverts commit e9819addf17d1407758acca179d02ffa9a09318d.
Revert "added Phil's changes, fixed seg-fault"

This reverts commit 28939f1b92961793c36f38e0c883a00a62067e67.