Some code prettyfying and get_activity fixup