Improve get_stub_size function