Switch to 'log' package
Fix infinite loop bug