Assorted code efficiency changes