Some more refactor and comments