Some additions needed for my project, will refactor and clean up later.