refactorings and better usage of raf