Clean and modularize ranger