Fixed Bugs, improved speed

Fixed some minor issues and improved both speed and stability