Cleaned up source, ready for actual implementation