Add some debug logging and fix a bug in expression evaluation