Fixes applyLayout bug