Minor fixes to optimize performance