Syntax and minor performance fixes