some merging and fixing