Cleaned up registration code