decrease size of input buffer, switch shorts to ints
fix bug in state machine