fixed missed beat bug and made everything use smart pointers instead