Fix some size calculation issues and simplify by removing some pointless code