Fully Working

Fully working version although EXTREMELY slow; need to investigate the
proper vectorized functions.