Fixed initial bugs found in testing environment