Added error (alert) and cleaned up global namespace.