Added support for current API levels. Minor code clean-up. Closes #47.