fixes / optimizations / json stuff