Initial commit. Works but could use tons of optimization.