Fix small bugs
Various modifications