generic object mapper and code clean up