Small internal changes + some api tweaks