Refactor janitor code (extract into separate package/classes)