Register collector
remove infinite loop
Major refactor/improvements from krobertson.