big merge, updated functionality