added hash function and init. needs testing for errors.