Fixed several serious issues