move some functions away from common.h
split up header files, make src pointer in write functions const