fixes bugs, reduces code. near stable.