Refactoring of alfred lib