Updated with changes to full, working version.