2nd draft, partial bug fixes.