Finished writeup + code tweaks