Performance improvements + bug fixes