Cleaned up recording code