Fixed numerous issues