More performance patches 

More performance patches replacing usage of size() by empty() to check for emptiness.