Fixed minor bugs
General bug fixes