Major bug fixes and some added features