Refactored for better maven compatibility