Fix unchecked cast and some Javadoc