Refactored code to make it cleaner.

Made Rankfinder modules and Matrix module is now generic.