Various helpers and fixes