Reworked to make it more general and added travis config