Cleaned up receiver code