Some improvements, a little bug fixes