Merged to most recent + added serilization functions