Cleaned primordial code and fixed a few minor bugs