Initial bug fixes

Found one bug with the first test expression I wrote.
Don't merge it yet, a little more test expression may possibly uncover something more.