main functionality mostly there, a few bugs.