Refactoring and added some sort tools..