Refactoring inspired from Apollo (Cyanogenmod)