Check for package definition before declaring. Tidy up naming.