Some perfomance fixes