add documentation, remove unused vars