Cleanup of the code base including combination of some functions.