Add missing ) and other bugfixes