Initial import. First working version with bug.