Hopefully finished fixing bugs