Keep defined accessibility modifier in source generation

@gunnarmorling, could you take a look and merge it, if you think it's ok?