small fixes; now accepts input on <stdin>