Inline a func and removed some dead code