Fix MainLoop usage

This fixes Issue #5, and also removes usage of a deprecated API