Remove unused globals and error variable