More rafactorig and cleanup