Refactored to use mostly bytes and bytearrays instead of various string representations