Compatibility with cocaine 0.10.6 + minor refactoring