Few improvements, also a few bug fixes