Refactor code, use OOP style for defining functions.
Fix function signature.