Small refactor and improvements.