Fixed issues with ClassCastExceptions in set max/init stack size