Minor fixes but mostly code changes