First version

Did some work late at night.