I would suggest to look into your hardware for those problems, software is executed fast, I don't think the lag could observed because of the software.
As for 2803, I couldn't tell unless a schematic is provided. Generally the ULN2803 is a driver, and does not have latch capabilities. Only external circuitry could lead to behaviour like that.