Fixed issue with message loop. Fixes #34