Privatisation of some API's and code cleanup