Major fixes (seems to work)