Removed debug code and code optimalisation