a few bug fixes and play around with swift protocols