Fix instruction reading and minor bug fixes.