Fix indexing for byte arrays and some improvements aside