Removed malloc usage in main encoding/decoding