updated database.py to stop metalock issues with MySql 5.5 and rewrote bittorrent file handling logic