The following code is a work in progress.
Please use it as a reference.