Fixed a couple of edge cases