Minor fixes, some efficiency changes