Refined a few things to make it more stable