Fixed various bugs. Throughput test works fine now