fixed many bugs

using atoms instead of indices...indices are way too mutable : (
now basically works for basic shiz