Cleaned things up a bit, moved to numpy arrays where possible