Updated hash functions and main (with ply write)