initial implementation, with some FIXMEs