Bug fix + input assertions.